home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / ui_setupP.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  7.0 KB  |  262 lines

  1. /*****************************************************************************
  2.   FILE           : ui_setupP.c
  3.   SHORTNAME      : setupP.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        :
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Tilman Sommer
  10.   DATE           : 23.7.1990
  11.  
  12.   CHANGED BY     :
  13.   IDENTIFICATION : @(#)ui_setupP.c    1.11 3/2/94
  14.   SCCS VERSION   : 1.11
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.              
  19. ******************************************************************************/
  20.  
  21.  
  22. #include <stdio.h>
  23.  
  24. #include "ui.h"
  25.  
  26. #include <X11/Xaw/Toggle.h>
  27.  
  28. #include "ui_selection.h"
  29. #include "ui_display.h"
  30. #include "ui_xWidgets.h"
  31. #include "ui_setup.h"
  32. #include "ui_layer.h"
  33. #include "ui_mainP.h"
  34. #include "ui_action.h"
  35.  
  36. #include "ui_setupP.ph"
  37.  
  38.  
  39. /*****************************************************************************
  40.   FUNCTION : ui_set_showProc
  41.  
  42.   PURPOSE  : callback. Called by menu items of SHOW menu buttons
  43.   RETURNS  : void
  44.   NOTES    :
  45.  
  46.   UPDATE   :
  47. *****************************************************************************/
  48.  
  49. void ui_set_showProc(Widget w, int value, caddr_t call_data)
  50.  
  51. {   
  52.     switch (value) {
  53.       case UI_ACTIVATION:
  54.     ui_xSetLabel(ui_showBottomLabel, "activation");
  55.     (ui_set_displayPtr->setup).showValue = UI_ACTIVATION;
  56.     break;
  57.       case UI_INITIAL_ACTIVATION:
  58.     ui_xSetLabel(ui_showBottomLabel, "initial act.");
  59.     (ui_set_displayPtr->setup).showValue = UI_INITIAL_ACTIVATION;
  60.     break;
  61.       case UI_OUTPUT:
  62.     ui_xSetLabel(ui_showBottomLabel, "output");
  63.     (ui_set_displayPtr->setup).showValue = UI_OUTPUT;
  64.     break;
  65.       case UI_BIAS:
  66.     ui_xSetLabel(ui_showBottomLabel, "bias");
  67.     (ui_set_displayPtr->setup).showValue = UI_BIAS;
  68.     break;
  69.       case UI_NAME:
  70.     ui_xSetLabel(ui_showTopLabel, "name");
  71.     (ui_set_displayPtr->setup).showTitle = UI_NAME;
  72.     break;
  73.       case UI_NUMBER:
  74.     ui_xSetLabel(ui_showTopLabel, "number");
  75.     (ui_set_displayPtr->setup).showTitle = UI_NUMBER;
  76.         break;
  77.       case UI_ZVALUE:
  78.     ui_xSetLabel(ui_showTopLabel, "z-value");
  79.     (ui_set_displayPtr->setup).showTitle = UI_ZVALUE;
  80.         break;
  81.     case UI_WINNER:
  82.     ui_xSetLabel(ui_showTopLabel, "winner");
  83.     (ui_set_displayPtr->setup).showTitle = UI_WINNER;
  84.     break;
  85.     }
  86. }
  87.  
  88.  
  89. /*****************************************************************************
  90.   FUNCTION : ui_set_getSetupData
  91.  
  92.   PURPOSE  : stores the current setting in the global variable ui_set_displayPtr->setup
  93.   RETURNS  : void
  94.   NOTES    : This is a callback of toggles.
  95.  
  96.   UPDATE   : 23.7.1990
  97. ******************************************************************************/
  98.  
  99. void ui_set_getSetupData(Widget widget, int toggleNumber, caddr_t call_data)
  100.  
  101. {
  102.     /* typedef char Boolean !! */
  103.  
  104.     switch (toggleNumber) {
  105.  
  106.       case UI_UNIT_TOP_GENERAL:
  107.     (ui_set_displayPtr->setup).showTitleFlg = ui_xGetToggleState(widget);
  108.     break;
  109.       case UI_UNIT_BOTTOM_GENERAL:
  110.     (ui_set_displayPtr->setup).showValueFlg = ui_xGetToggleState(widget);
  111.     break;
  112.       case UI_LINK_GENERAL:
  113.     (ui_set_displayPtr->setup).showLinkFlg = ui_xGetToggleState(widget);
  114.     break;
  115.       case UI_LINK_VALUE:
  116.     (ui_set_displayPtr->setup).showWeightFlg = ui_xGetToggleState(widget);
  117.     break;
  118.       case UI_LINK_DIRECTION:
  119.     (ui_set_displayPtr->setup).showDirectionFlg = ui_xGetToggleState(widget);
  120.     break;
  121.     }
  122. }
  123.  
  124.  
  125. /*****************************************************************************
  126.   FUNCTION : ui_set_assignLayers
  127.  
  128.   PURPOSE  : popup the layer assignment window.
  129.   RETURNS  : void
  130.   NOTES    : 
  131.  
  132.   UPDATE   :
  133. *****************************************************************************/
  134.  
  135. void ui_set_assignLayers(Widget w, caddr_t client_data, caddr_t call_data)
  136.  
  137. {
  138.     Arg        args[5];
  139.     Position    x, y;
  140.     Dimension    width, height;
  141.     Cardinal    n;
  142.  
  143.     /* Upper left corner will be in the center of the calling button */
  144.  
  145.     n = 0;
  146.     XtSetArg(args[n], XtNwidth, &width); n++;
  147.     XtSetArg(args[n], XtNheight, &height); n++;
  148.     XtGetValues(w, args, n);
  149.     XtTranslateCoords(w, (Position) (width / 2), (Position) (height / 2),
  150.               &x, &y);
  151.  
  152.     /* set start value for the buttons */
  153.     ui_layerStartValue = ui_set_displayPtr->layers;
  154.     ui_displayLayerPanel(x,y); /* absolute screen coordinates */
  155.     /* assign return value */
  156.     ui_set_displayPtr->layers = ui_layerReturnValue;
  157.     ui_sel_checkList(ui_set_displayPtr, UI_GLOBAL);
  158. }
  159.  
  160.  
  161. /*****************************************************************************
  162.   FUNCTION : ui_scrolled
  163.  
  164.   PURPOSE  : Prints the location of the pointer 
  165.   RETURNS  : void
  166.   NOTES    : value_ptr - the amount the bar has been scrolled.
  167.  
  168.   UPDATE   : 2.8.1990
  169. ******************************************************************************/
  170.  
  171. void ui_scrolled(Widget widget, caddr_t label_ptr, XtPointer value_ptr)
  172.  
  173. {
  174.     int value = (int) value_ptr;
  175.     char message[80];
  176.  
  177.     sprintf( message, " Scrolled by %d pixels", value);
  178.     ui_printMessage(message);
  179. }
  180.  
  181.  
  182. /*****************************************************************************
  183.   FUNCTION : ui_thumbed
  184.  
  185.   PURPOSE  : Prints the location of the thumb as a percentage of the height
  186.   RETURNS  : void
  187.   NOTES    : top_ptr - a pointer to a float containing the location of 
  188.                        of the scrollbar's thumb
  189.  
  190.   UPDATE   : 2.8.1990
  191. ******************************************************************************/
  192.  
  193. void ui_thumbed(Widget widget, int trigger, XtPointer top_ptr)
  194.  
  195. {
  196.     float top = *(float *) top_ptr;
  197.     char  buf[80];
  198.  
  199.     switch (trigger) {
  200.       case UI_LINKS_POS:
  201.     sprintf(buf,"links pos: %8.5f = %.1f%%", 
  202.         ((ui_set_displayPtr->setup).linkPosTrigger = 
  203.          top * ui_maxWeight), (100.0 * top));
  204.     break;
  205.       case UI_LINKS_NEG:
  206.     sprintf(buf,"links neg:  %8.5f = %.1f%%", 
  207.         ((ui_set_displayPtr->setup).linkNegTrigger = 
  208.          top * ui_minWeight), (100.0 * top));
  209.     break;
  210.      case UI_SCALE_FACTOR:
  211.     (ui_set_displayPtr->setup).unitScaleFactor = top * ui_maxAct;
  212.     if ((ui_set_displayPtr->setup).unitScaleFactor <= 0) {
  213.         (ui_set_displayPtr->setup).unitScaleFactor = 1;
  214.     }
  215.     sprintf(buf,"scale factor: %8.5f = %.1f%%", top * ui_maxAct, (100.0 * top));
  216.     break;
  217.      case UI_SCALE_LINKS:
  218.     (ui_set_displayPtr->setup).linkScaleFactor = top * 10.0;
  219.     if ((ui_set_displayPtr->setup).unitScaleFactor <= 0) {
  220.         (ui_set_displayPtr->setup).unitScaleFactor = 1;
  221.     }
  222.     sprintf(buf,"scale links: %8.5f = %.1f%%", top * 10.0, (100.0 * top));
  223.     break;
  224.     }
  225.     ui_xSetLabel(ui_setupSliderMessage, buf);
  226. }
  227.  
  228.  
  229. /*****************************************************************************
  230.   FUNCTION : ui_set_colorProc
  231.  
  232.   PURPOSE  : called by menu items of COLOR menu button in monochrome mode
  233.   RETURNS  : void
  234.   NOTES    :
  235.  
  236.   UPDATE   :
  237. *****************************************************************************/
  238.  
  239. void ui_set_colorProc(Widget w, int value, caddr_t call_data)
  240.  
  241. {    
  242.     if (value == UI_PALETTE_MONO) {
  243.         ui_set_displayPtr->setup.backgroundColorIndex = UI_WHITE;
  244.         ui_set_displayPtr->setup.textColorIndex = UI_BLACK;
  245.     } else {
  246.         ui_set_displayPtr->setup.backgroundColorIndex = UI_BLACK;
  247.         ui_set_displayPtr->setup.textColorIndex = UI_WHITE;
  248.     }
  249. }
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260. /* end of file */
  261. /* lines: 267 */
  262.